import Response from '../assets/js/response';

const articles = [
  {
    id: 1,
    title: '[开盘报]测试',
    desc: '23',
    content: [
      {
        type: 'List',
        title: '全球股市上一交易日',
        data: {
          data: [
            {
              name: '纳斯达克',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '标普500',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '道琼斯',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '德国DAX30',
              current: '1166.2',
              zdf: '1.20%'
            }
          ],
          fields: [
            {
              name: 'name',
              title: '股市'
            },
            {
              name: 'current',
              title: '当前点数'
            },
            {
              name: 'zdf',
              title: '涨跌幅',
              color: true
            }
          ]
        }
      },
      {
        type: 'List',
        title: '期指情况',
        data: {
          data: [
            {
              name: '纳斯达克',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '纳斯达克',
              current: '1166.2',
              zdf: '1.20%'
            }
          ],
          fields: [
            {
              name: 'name',
              title: '股市'
            },
            {
              name: 'current',
              title: '当前点数'
            },
            {
              name: 'zdf',
              title: '涨跌幅',
              color: true
            }
          ]
        }
      },
      {
        type: 'Grid',
        title: '可转债打新',
        data: [
          {
            name: '精达转债',
            code: '111111',
            pj: 'AA',
            gm: '11',
            xjbzgj: '96.20%'
          },
          {
            name: '精达转债',
            pj: 'AA',
            gm: '11',
            code: '222',
            xjbzgj: '96.20%'
          },
        ]
      },
      {
        type: 'List',
        title: '可转债战绩',
        data: {
          data: [
            {
              name: '沪股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '北向资金',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'name',
              title: '可转债'
            },
            {
              name: 'current',
              title: '中签数'
            },
            {
              name: 'sale',
              title: '卖出价'
            },
            {
              name: 'zdf',
              title: '收益率',
              color: true
            }
          ],
          showHeader: true
        }
      },
      {
        type: 'LineChart',
        title: '新闻大件事',
        data: {
          data: [],
          fields: []
        }
      },
      {
        type: 'LineChart',
        title: '主要估值表',
        data: {
          data: [],
          fields: []
        }
      }
    ]
  },
  {
    id: 2,
    title: '[午间报]测试',
    desc: '24',
    content: [
      {
        type: 'LineChart',
        title: '市场量能',
        data: {
          data: [
            {
              year: '上证量能',
              sales: 38
            },
            {
              year: '昨日此时',
              sales: 52
            },
            {
              year: '昨日总计',
              sales: 61
            },
            {
              year: '全市场量能',
              sales: 145
            },
            {
              year: '昨日此时 ',
              sales: 48
            },
            {
              year: '昨日总计 ',
              sales: 38
            }
          ],
          fields: ['year', 'sales']
        }
      },
      {
        type: 'List',
        title: '北向资金',
        data: {
          data: [
            {
              name: '沪股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '北向资金',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'name',
            },
            {
              name: 'current',
            },
            {
              name: 'zdf',
              color: true
            }
          ]
        }
      },
      {
        type: 'List',
        title: '今日资金流向',
        data: {
          data: [
            {
              name: '主力净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '超大单净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '大单净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '中单净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '小单净流入',
              current: '1166.2',
              zdf: '1.20%'
            }
          ],
          fields: [
            {
              name: 'name',
            },
            {
              name: 'current',
            },
            {
              name: 'zdf',
              color: true
            }
          ]
        }
      },
    ]
  },
  {
    id: 3,
    title: '[收盘报]测试',
    desc: '24',
    content: [
      {
        type: 'Histogram',
        title: '涨跌分布',
        data: {
          data: [
            {
              year: '1951 年',
              sales: 38
            },
            {
              year: '1952 年',
              sales: 52
            },
            {
              year: '1956 年',
              sales: 61
            },
            {
              year: '1957 年',
              sales: 145
            },
            {
              year: '1958 年',
              sales: 48
            },
            {
              year: '1959 年',
              sales: 38
            },
            {
              year: '1960 年',
              sales: 38
            },
            {
              year: '1962 年',
              sales: 38
            }
          ],
          fields: ['year', 'sales']
        }
      },
      {
        type: 'LineChart',
        title: '市场量能',
        data: {
          data: [
            {
              year: '上证量能',
              sales: 38
            },
            {
              year: '昨日此时',
              sales: 52
            },
            {
              year: '昨日总计',
              sales: 61
            },
            {
              year: '全市场量能',
              sales: 145
            },
            {
              year: '昨日此时 ',
              sales: 48
            },
            {
              year: '昨日总计 ',
              sales: 38
            }
          ],
          fields: ['year', 'sales']
        }
      },
      {
        type: 'List',
        title: '今日资金流向',
        data: {
          data: [
            {
              name: '主力净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '超大单净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '大单净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '中单净流入',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '小单净流入',
              current: '1166.2',
              zdf: '1.20%'
            }
          ],
          fields: [
            {
              name: 'name',
            },
            {
              name: 'current',
            },
            {
              name: 'zdf',
              color: true
            }
          ]
        }
      },
      {
        type: 'List',
        title: '大A股',
        data: {
          data: [
            {
              name: '上证指数',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深证成指',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '创业板',
              current: '1166.2'
            },
            {
              name: '中小板',
              current: '1166.2'
            },
            {
              name: '科创50',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'name',
            },
            {
              name: 'current',
            },
            {
              name: 'zdf',
              color: true
            }
          ]
        }
      },
      {
        type: 'List',
        title: '北向资金',
        data: {
          data: [
            {
              name: '沪股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '北向资金',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'name',
            },
            {
              name: 'current',
            },
            {
              name: 'zdf',
              color: true
            }
          ]
        }
      },
    ]
  },
  {
    id: 4,
    title: '[操作贴]测试',
    desc: '24',
    content: [
      {
        type: 'LineChart',
        title: '网格交易',
        data: {
          data: [],
          fields: []
        }
      },
      {
        type: 'LineChart',
        title: '额外操作',
        data: {
          data: [],
          fields: []
        }
      },
      {
        type: 'LineChart',
        title: '我的持仓',
        data: {
          data: [],
          fields: []
        }
      },
      {
        type: 'List',
        title: '期指情况',
        data: {
          data: [
            {
              name: '纳斯达克',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '纳斯达克',
              current: '1166.2',
              zdf: '1.20%'
            }
          ],
          fields: [
            {
              name: 'name',
              title: '股市'
            },
            {
              name: 'current',
              title: '当前点数'
            },
            {
              name: 'zdf',
              title: '涨跌幅',
              color: true
            }
          ]
        }
      }
    ]
  },
  {
    id: 5,
    title: '[知识贴]测试',
    desc: '24',
    content: [
      {
        type: 'LineChart',
        title: '知识点',
        data: {
          data: [],
          fields: []
        }
      }
    ]
  },
  {
    id: 6,
    title: '[ETF分析] 单个ETF',
    desc: '24',
    content: [
      {
        type: 'Description',
        title: '沪深300',
        data: '中证申万医药生物指数从沪深A股中挑选日均总市值前100的医药生物行业公司股票组成样本股，以反映医药生物行业公司股票的整体走势。'
      },
      {
        type: 'Pie',
        title: '行业权重分布',
        data: [
          {
            name: '芳华',
            percent: 0.4,
            a: '1'
          },
          {
            name: '妖猫传',
            percent: 0.2,
            a: '1'
          }, {
            name: '机器之血',
            percent: 0.18,
            a: '1'
          }, {
            name: '心理罪',
            percent: 0.15,
            a: '1'
          }, {
            name: '寻梦环游记',
            percent: 0.05,
            a: '1'
          }, {
            name: '其他',
            percent: 0.02,
            a: '1'
          }
        ]
      },
      {
        type: 'List',
        title: '业绩',
        data: {
          data: [
            {
              name: '沪股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '北向资金',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'sale',
              title: '代码'
            },
            {
              name: 'name',
              title: '简称'
            },
            {
              name: 'current',
              title: '行业'
            },
            {
              name: 'zdf',
              title: '权重'
            }
          ],
          showHeader: true
        }
      },
      {
        type: 'List',
        title: '对应ETF',
        data: {
          data: [
            {
              name: '沪股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '北向资金',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'sale',
              title: '代码'
            },
            {
              name: 'name',
              title: '简称'
            },
            {
              name: 'current',
              title: '行业'
            },
            {
              name: 'zdf',
              title: '权重'
            }
          ],
          showHeader: true
        }
      },
      {
        type: 'List',
        title: '十大权重股',
        data: {
          data: [
            {
              name: '沪股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '深股通',
              current: '1166.2',
              zdf: '1.20%'
            },
            {
              name: '北向资金',
              current: '1166.2'
            }
          ],
          fields: [
            {
              name: 'sale',
              title: '代码'
            },
            {
              name: 'name',
              title: '简称'
            },
            {
              name: 'current',
              title: '行业'
            },
            {
              name: 'zdf',
              title: '权重'
            }
          ],
          showHeader: true
        }
      }
    ]
  },
  {
    id: 7,
    title: '[ETF] ETF市场',
    desc: '24',
    content: [
      {
        type: 'LineChart',
        title: 'ETF',
        data: {
          data: [],
          fields: []
        }
      }
    ]
  }
];

export default {
  'get /article/list': () => {
    return new Response(articles);
  },
  'get /article/query': (options) => {
    const { id } = options.query;
    if (id === undefined) {
      return new Response(null, 1, 'id error');
    }

    for (const article of articles) {
      if (article.id === id) {
        return new Response(article);
      }
    }

    return new Response(null, 1, 'id error');
  }
};
